refactor(atomic): migrate atomic-insight-search-box to Lit#6881
refactor(atomic): migrate atomic-insight-search-box to Lit#6881alexprudhomme merged 12 commits intomainfrom
Conversation
…ncil to Lit Co-authored-by: alexprudhomme <78121423+alexprudhomme@users.noreply.github.com>
…h-box Co-authored-by: alexprudhomme <78121423+alexprudhomme@users.noreply.github.com>
98fbe02 to
1eddff3
Compare
packages/atomic/src/components/common/suggestions/query-suggestions.spec.ts
Show resolved
Hide resolved
...es/atomic/src/components/insight/atomic-insight-search-box/atomic-insight-search-box.spec.ts
Show resolved
Hide resolved
erocheleau
left a comment
There was a problem hiding this comment.
I know this was already merged, but I do have some comments and questions as there are changes between the stencil version and this one.
| expect(icon).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('should render the icon when alwaysShowIcon is true even if hasMultipleKindOfSuggestions is false', async () => { |
There was a problem hiding this comment.
Not sure I'm clear on the relation between hasMultipleKindOfSuggestions and the option alwaysShowIcon ?
There was a problem hiding this comment.
alwaysShowIcon is an override that forces the icon to display even when hasMultipleKindOfSuggestions is false (which normally hides icons when there's only one suggestion type).
| * When true, the icon will always be displayed regardless of hasMultipleKindOfSuggestions. | ||
| * Used by the insight search box where icons should always be visible. | ||
| */ | ||
| alwaysShowIcon?: boolean; |
There was a problem hiding this comment.
What's that exactly?
The icon next to the query suggestions?
There was a problem hiding this comment.
yes exactly. For search we dont always show it
| const {textArea} = await renderComponent(); | ||
| await userEvent.type(textArea, 'test'); | ||
| expect(dispatchSpy).toHaveBeenCalledWith( | ||
| expect.objectContaining({type: 'fetchQuerySuggestions'}) |
There was a problem hiding this comment.
Can we also validate here that it was called with the right query value?
There was a problem hiding this comment.
yes we could do that.
...es/atomic/src/components/insight/atomic-insight-search-box/atomic-insight-search-box.spec.ts
Show resolved
Hide resolved
packages/atomic/src/components/insight/atomic-insight-search-box/atomic-insight-search-box.ts
Show resolved
Hide resolved
packages/atomic/src/components/insight/atomic-insight-search-box/atomic-insight-search-box.ts
Show resolved
Hide resolved
| hasMultipleKindOfSuggestions: false, | ||
| alwaysShowIcon: this.searchBoxState.suggestions.length > 1, |
There was a problem hiding this comment.
I'm still unclear on the relation between these two attributes that seem to decide if we're supposed to render an icon or not?
There was a problem hiding this comment.
When suggestions are there, we want to always show an icon for insight. Search has logic for this, insight just always shows an icon so I added this prop to make it work.
| getRef: () => HTMLElement | undefined | ||
| ): TemplateResult | typeof nothing { | ||
| if (!elements.length) { | ||
| return nothing; |
There was a problem hiding this comment.
Again with the nothing instead of null?
Is it expected that the lit nothing is not the same type as TemplateResult ?
There was a problem hiding this comment.
Yes it is expected and quite annoying imo, we had to add it in some internal types.
✅ Checklist
.mdxfileindex.tsandlazy-index.tsfiles.https://coveord.atlassian.net/browse/KIT-4933